<?php

class FormatAction extends CommonAction {
    /*
     * 生成表格HTML
     */

    public function createHtml() {
        $model = M('TableFormat');
        $list = $model->query('select distinct tablename from lt_table_format order by px');
        $this->assign('tablenames', $list);
        $this->display();
    }

    public function gethtml() {
        if (empty($_GET['tbname'])) {
            $this->ajaxReturn('', '请选择数据表!', 0);
        }
        $html = '<table cellpadding=3 cellspacing=5>';
        $model = M('TableFormat');
        $list = $model->where(array('tablename'=>$_GET['tbname']))->order('px')->select();
        $header = '';
        foreach ($list as $row){
            $header.="<th ";
            if (!empty($row['tdhtml'])){
                $header.=$row['tdhtml'];
            }
            $header.='>';
            if ($row['is_sort']){
                $header.="<a href='__URL__/index/order/".$row['fieldname']."/sort/<eq name="order['order']" value=""> {$order['sort']}<else/>asc</eq>'>"
            }
            $header.=$row['fieldtitle'];
            $header.='</th>';
        }
        $html.='<tr>';
        $html.=$header.'</tr>';
        $html.='</table>';
        $this->ajaxReturn($html, '成功!', 1);
    }

}

?>
